package com.briup.app01.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app01.bean.Category;
import com.briup.app01.service.ICategoryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/category")
@Api(description ="栏目管理")
public class CategoryController {
	
	
	@Autowired
	private ICategoryService categoryService;
	
	@GetMapping("findAll")
	@ApiOperation("查询所有栏目信息")
	public List<Category> findAll(){
		return categoryService.findAll();
	}
	@GetMapping("selectById")
	@ApiOperation("根据id查询单个栏目信息")
	@ApiImplicitParam(name="id",value ="栏目id",dataType="long",paramType="query",required=true )
	public Category selectById(long id){
		return categoryService.selectById(id);
	}
	@PostMapping("saveOrUpdate")
	@ApiOperation(value="插入或更新栏目信息",notes="id为空是保存，否则是更新")
	public String saveOrUpdate(Category category){
		categoryService.saveOrUpdate(category);
		return "成功";
	}
	@DeleteMapping("deleteById")
	@ApiOperation("删除栏目信息")
	@ApiImplicitParam(name="id",value="栏目id",dataType="long",paramType="query",required=true)
	public String deleteById(long id){
		categoryService.deleteById(id);
		return "删除成功";
	}
}
